const mongooose = require("mongoose")
const Schema=new mongooose.Schema({
    username: { type: String, unique: true },
    //set函数表示更改值—可以对要保存的数据进行操作 req为用户原本的string值
    //select:false 默认返回数据的时候不带此数据
    password: {
        type: String, select: false, set: (req) => {
            //哈希加密  =>req是原数据  10是加密值，任意写
            return require('bcryptjs').hashSync(req, 10)
        }
    },
    parent: { type: mongooose.Schema.Types.ObjectId, ref: 'adminusers' }
})
const model= mongooose.model('adminusers',Schema)
module.exports =model